<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
    <meta charset="UTF-8">
    <title></title>
    <h1>测试</h1>
    <script type="text/javascript">
        // 假设服务端ip为127.0.0.1
        ws = new WebSocket("ws://127.0.0.1:2346");
        ws.onopen = function() {
            console.log("连接成功");
            ws.send('tom');
            console.log("给服务端发送一个字符串：tom");
        };
        ws.onmessage = function(e) {
            console.log("收到服务端的消息：" + e.data);
        };
    </script>
</head>
<body>
</body>
</html>